﻿using System;
using System.Collections;

namespace SortedListPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sortedList = new SortedList();
            sortedList.Add(1, "董卓");
            sortedList.Add(2, "吕布");
            sortedList.Add(3, "贾诩");
            sortedList.Add(4, "李儒");
            sortedList.Add(5, "华雄");
            sortedList.Add(6, "李傕");
            sortedList.Add(7, "郭汜");
            Console.WriteLine("请输入参与者编号：");
            int id = int.Parse(Console.ReadLine());
            bool signal = sortedList.ContainsKey(id);
            if (signal)
            {
                string n = sortedList[id].ToString();
                Console.WriteLine("你要查询的当年太师动乱的参与者名字为：{0}", n);
            }
            else
            {
                Console.WriteLine("你查询的角色不存在");
            }
            Console.WriteLine("所有太师动乱参与者信息如下：");
            foreach (DictionaryEntry dictionary in sortedList)
            {
                int number = (int)dictionary.Key;
                string name = dictionary.Value.ToString();
                Console.WriteLine("角色编号：{0},姓名：{1}", number, name);
            }
        }
    }
}
